<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>伪类选择器 | Welcome to use MarkDown</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="gitbook/style.css">
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="./shuxingxuanzeqi.html" />
    
    
    <link rel="prev" href="./guanxixuanzeqi.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="1.6"
        data-chapter-title="伪类选择器"
        data-filepath="weileixuanzeqi.md"
        data-basepath="."
        data-revision="Tue Dec 12 2017 20:29:49 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="./index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="section1/index.html">
            
                
                    <a href="./section1/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        css
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="dizhi.html">
            
                
                    <a href="./dizhi.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        example 1
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="section2/css.html">
            
                
                    <a href="./section2/css.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        css的引用方式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="css.html">
            
                
                    <a href="./css.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        元素选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="class and id.html">
            
                
                    <a href="./class and id.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        class和id选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="guanxixuanzeqi.html">
            
                
                    <a href="./guanxixuanzeqi.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        关系选择器
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="1.6" data-path="weileixuanzeqi.html">
            
                
                    <a href="./weileixuanzeqi.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        伪类选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="shuxingxuanzeqi.html">
            
                
                    <a href="./shuxingxuanzeqi.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.</b>
                        
                        属性选择器
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="section2/index.html">
            
                
                    <a href="./section2/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        html
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="abiaoqian.html">
            
                
                    <a href="./abiaoqian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        a标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="abiaoqianmaodian.html">
            
                
                    <a href="./abiaoqianmaodian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        a标签锚点
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="img.html">
            
                
                    <a href="./img.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        img
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="biaoqian.html">
            
                
                    <a href="./biaoqian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="requ.html">
            
                
                    <a href="./requ.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        热区
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="yuansu.html">
            
                
                    <a href="./yuansu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        认识页面以及认识行内和块级元素
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="./" >Welcome to use MarkDown</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x5668;">&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x5668;</h1>
<pre><code>    ul li:first-of-type{ /*ul&#x4E0B;&#x9762;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;li&#x7C7B;&#x578B;&#x7684;&#x5B50;&#x5143;&#x7D20;*/
        background: purple
    }
    ul :first-child{/*ul&#x4E0B;&#x9762;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;*/
        background: skyblue
    }
    ul li:first-child{/*ul&#x4E0B;&#x9762;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;&#xFF0C;&#x5E76;&#x4E14;&#x662F;li&#x7C7B;&#x578B;&#xFF0C;&#x6240;&#x4EE5;&#x8FD9;&#x91CC;&#x662F;&#x4E0D;&#x7B26;&#x5408;&#x73B0;&#x6709;&#x6761;&#x4EF6;&#xFF0C;&#x662F;&#x4E0D;&#x4F1A;&#x751F;&#x6548;&#x7684;
    background: skyblue
    }

    &#x4F2A;&#x7C7B;css
    &#x6307;&#x660E;&#x7236;&#x5143;&#x7D20;&#xFF0C;&#x5219;&#x8868;&#x793A;&#x5168;&#x9875;&#x9762;&#x641C;&#x7D22;&#x7B26;&#x5408;&#x7684;&#x5B50;&#x5143;&#x7D20;
    &#x5C3D;&#x91CF;&#x4E0D;&#x8981;&#x8FD9;&#x6837;&#x5B50;&#x5199;&#xFF0C;&#x56E0;&#x4E3A;&#x6548;&#x7387;&#x4F4E;&#xFF0C;&#x6240;&#x4EE5;&#x5E94;&#x8BE5;&#x5C3D;&#x53EF;&#x80FD;&#x52A0;&#x4E0A;&#x4E00;&#x4E2A;&#x7236;&#x5143;&#x7D20;&#xFF0C;&#x7F29;&#x5C0F;&#x641C;&#x7D22;&#x7684;&#x8303;&#x56F4;
</code></pre><h3 id="nthchild-nthoftype----&#x533A;&#x522B;">nth-child nth-of-type    &#x533A;&#x522B;</h3>
<p>nth-child&#x53EF;&#x4EE5;&#x9009;&#x62E9;&#x7236;&#x5143;&#x7D20;&#x4E0B;&#x7684;&#x5B57;&#x5143;&#x7D20;&#xFF0C;nth-of-type&#x4E5F;&#x53EF;&#x4EE5;&#x3002;&#x4F46;&#x662F;&#x5B83;&#x4EEC;&#x5230;&#x5E95;&#x6709;&#x4EC0;&#x4E48;&#x533A;&#x522B;&#x5462;&#xFF1F; </p>
<pre><code>        1.    &#x5982;&#x679C;&#x5B50;&#x5143;&#x7D20;&#x7684;&#x7C7B;&#x578B;&#x4E0D;&#x5B9A;&#xFF0C;&#x4F46;&#x4F4D;&#x7F6E;&#x76F8;&#x5BF9;&#x56FA;&#x5B9A;&#xFF0C;&#x5E94;&#x8BE5;&#x9009;&#x62E9;nth-child&#x7CFB;&#x5217;&#xFF0C;&#x76F4;&#x63A5;&#x7C97;&#x66B4;&#x76F4;&#x63A5;&#xFF0C;&#x6839;&#x636E;&#x4F4D;&#x7F6E;&#x51B3;&#x5B9A;
        2.    &#x5982;&#x679C;&#x5B50;&#x5143;&#x7D20;&#x76F8;&#x5BF9;&#x56FA;&#x5B9A;&#x4E14;&#x7EDF;&#x4E00;&#xFF0C;&#x5E94;&#x8BE5;&#x9009;&#x62E9;nth-of-type&#x7CFB;&#x5217;&#xFF0C;&#x6548;&#x7387;&#x66F4;&#x9AD8;
        3.    nth-child&#x7CFB;&#x5217;&#xFF0C;&#x9996;&#x8981;&#x6761;&#x4EF6;&#x662F;&#x7B26;&#x5408;&#x4F4D;&#x7F6E;&#xFF0C;&#x7136;&#x540E;&#x624D;&#x8003;&#x8651;&#x6307;&#x5B9A;&#x7684;&#x5143;&#x7D20;&#x7C7B;&#x578B;
        4.    nth-of-type&#x7CFB;&#x5217;&#xFF0C;&#x9996;&#x8981;&#x6761;&#x4EF6;&#x5FC5;&#x987B;&#x662F;&#x6307;&#x5B9A;&#x7684;&#x5143;&#x7D20;&#x7C7B;&#x578B;&#xFF0C;&#x7136;&#x540E;&#x624D;&#x8003;&#x8651;&#x4F4D;&#x7F6E;
</code></pre><h3 id="&#x4F8B;&#x5982;">&#x4F8B;&#x5982;</h3>
<pre><code>&lt;li&gt;one&lt;/li&gt;
&lt;li&gt;two&lt;/li&gt;
nth-child(1)&#x9009;&#x62E9;&#x7684;&#x662F;&lt;li&gt;one&lt;/li&gt;
nth-of-type(2)&#x9009;&#x62E9;&#x7684;&#x662F;&lt;li&gt;two&lt;/li&gt;
</code></pre><h3 id="&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x5668;">&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x5668;(:)</h3>
<pre><code>&#x5728;&#x6307;&#x5B9A;&#x8303;&#x56F4;&#x5185;&#x7684;&#x5143;&#x7D20;&#xFF0C;&#x7CBE;&#x7EC6;&#x63A7;&#x5236;&#x5176;&#x4E2D;&#x67D0;&#x4E00;&#x4E2A;&#x5143;&#x7D20;
&#x6CE8;&#x610F;:&#x5BF9;&#x73B0;&#x6709;&#x7684;&#x76EE;&#x6807;&#x5143;&#x7D20;&#xFF0C;&#x8FDB;&#x884C;&#x66F4;&#x52A0;&#x8BE6;&#x7EC6;&#x7684;&#x72B6;&#x6001;&#x63A7;&#x5236;
.nav li:first-child{
            color: skyblue;
        }
        .nav li:last-child{
            color: darkblue;
        }
        .nav li:nth-child(2){
            color: yellow;
        }
&#x6839;&#x636E;&#x6307;&#x5B9A;&#x5143;&#x7D20;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x6765;&#x505A;&#x7CBE;&#x51C6;&#x63A7;&#x5236;
.nav li:last-of-type{
            color: pink;
        }
        .nav li:first-of-type{
            color: purple;
        }
        .nav li:nth-of-type{
            color: yellow;
        }
</code></pre><h3 id="&#x7F13;&#x52A8;&#x52A8;&#x753B;">&#x7F13;&#x52A8;&#x52A8;&#x753B;</h3>
<pre><code>.nav&gt;li{
            color: black;
            transition: all 300ms linear;     
        }
</code></pre><h4 id="link-&#x9009;&#x62E9;&#x5668;&#x5BF9;&#x6307;&#x5411;&#x672A;&#x88AB;&#x8BBF;&#x95EE;&#x9875;&#x9762;&#x7684;&#x94FE;&#x63A5;&#x8BBE;&#x7F6E;&#x6837;&#x5F0F;">link &#x9009;&#x62E9;&#x5668;&#x5BF9;&#x6307;&#x5411;&#x672A;&#x88AB;&#x8BBF;&#x95EE;&#x9875;&#x9762;&#x7684;&#x94FE;&#x63A5;&#x8BBE;&#x7F6E;&#x6837;&#x5F0F;</h4>
<pre><code>a:link{color:blue;}
</code></pre><h4 id="visited-&#x7528;&#x4E8E;&#x8BBE;&#x7F6E;&#x6307;&#x5411;&#x5DF2;&#x8BBF;&#x95EE;&#x9875;&#x9762;&#x7684;&#x94FE;&#x63A5;&#x7684;&#x6837;&#x5F0F;">visited &#x7528;&#x4E8E;&#x8BBE;&#x7F6E;&#x6307;&#x5411;&#x5DF2;&#x8BBF;&#x95EE;&#x9875;&#x9762;&#x7684;&#x94FE;&#x63A5;&#x7684;&#x6837;&#x5F0F;</h4>
<pre><code>a:visited {color:blue;}
</code></pre><h4 id="hover-&#x9009;&#x62E9;&#x5668;&#x7528;&#x4E8E;&#x8BBE;&#x7F6E;&#x9F20;&#x6807;&#x6307;&#x9488;&#x6D6E;&#x52A8;&#x5230;&#x94FE;&#x63A5;&#x4E0A;&#x65F6;&#x7684;&#x6837;&#x5F0F;">hover &#x9009;&#x62E9;&#x5668;&#x7528;&#x4E8E;&#x8BBE;&#x7F6E;&#x9F20;&#x6807;&#x6307;&#x9488;&#x6D6E;&#x52A8;&#x5230;&#x94FE;&#x63A5;&#x4E0A;&#x65F6;&#x7684;&#x6837;&#x5F0F;</h4>
<pre><code>a:hover{color:red;}
</code></pre><h4 id="active-&#x9009;&#x62E9;&#x5668;&#x7528;&#x4E8E;&#x9009;&#x62E9;&#x6D3B;&#x52A8;&#x94FE;&#x63A5;">active &#x9009;&#x62E9;&#x5668;&#x7528;&#x4E8E;&#x9009;&#x62E9;&#x6D3B;&#x52A8;&#x94FE;&#x63A5;</h4>
<pre><code>a:active{color:yellow;}
</code></pre><h4 id="ul&#x8981;&#x52A0;class">ul&#x8981;&#x52A0;class</h4>
<pre><code>    &lt;ul class=&quot;nav&quot;&gt;
        &lt;li&gt;&lt;a href=&quot;http://bulejj.com&quot;&gt;&#x65B0;&#x95FB;1&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;http://bulejj.com&quot;&gt;&#x65B0;&#x95FB;2&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;http://bulejj.com&quot;&gt;&#x65B0;&#x95FB;3&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;http://bulejj.com&quot;&gt;&#x65B0;&#x95FB;4&lt;/a&gt;&lt;/li&gt;
        &lt;div&gt;12&lt;/div&gt;
    &lt;/ul&gt;
</code></pre>
                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="./guanxixuanzeqi.html" class="navigation navigation-prev " aria-label="Previous page: 关系选择器"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="./shuxingxuanzeqi.html" class="navigation navigation-next " aria-label="Next page: 属性选择器"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="gitbook/app.js"></script>

    
    <script src="gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"livereload":{}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
